app.controller('vipMessageNewphonePageCtrl',function($scope,$state,PopupService,$stateParams,$http,$myconfig,$timeout,$mydialog,$ionicConfig){
    //接收上一面传送的参数
    var change_mobile = JSON.parse($stateParams.NewPon);
    $scope.change_mobile = {
        old_mobile:change_mobile.mobile,
        code:change_mobile.code_type
    };
    // console.log($scope.newPhon);

    //执行修改函数
    $scope.saveChange = function(){
        $http.post($myconfig.api.base_host + '/users/change_mobile',{
            "old_mobile":$scope.change_mobile.old_mobile,
            "new_mobile":$scope.change_mobile.new_mobile,
            "code":$scope.change_mobile.code
        }).then(function(res){
            if(res.data.success){
                $scope.success_text = '更改成功，请重新登录';
                $mydialog.success($scope);
                localStorage.clear();
                $state.go('app.login');
            }else{
                $scope.err = res.data.data;
                $mydialog.fail($scope);
            }
        })
    };

    $scope.$on('$ionicView.enter', function(){

        $ionicConfig.views.swipeBackEnabled(false);

    });

});
